<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
	<meta name="format-detection" content="telephone=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<title>商品-{$webseting.web_title}</title>
	<script type="text/javascript" src="__PUBLIC__/wap/js/flexible.js"></script>
	<script type="text/javascript" src="__PUBLIC__/wap/js/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/wap/js/jquery.fly.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
	<link href="__PUBLIC__/wap/css/icons.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/base.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/swiper.min.css" />
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/public.css" />
	<if condition="$vip_type eq 1">
		<!-- <style>
            .s_price{
                display: inline-block;
            }
        </style>-->
	</if>
</head>
<body>
<body class="category" ontouchstart="" onmouseover="">
<div class="head">
    <a href="javascript:history.go(-1)" class="md-close back"><i class="iconfont">&#xe617</i></a>
    <h2 >分类</h2>
</div>
<div class="bggreen">
	<div class="catnav">
		<ul>
			<li
			<if condition="$_GET['type'] eq 98">class="on"</if>
			>
			<a href="{$return_url}?type=98&share={$share_para}" title="水果">
				<img src="/Public/wap/img/caticon/shuiguo.jpg">
			</a>
			<h4>水果</h4>
			</li>
			<li
			<if condition="$_GET['type'] eq 95">class="on"</if>
			>
			<a href="{$return_url}?type=95&share={$share_para}" title="干货">
				<img src="/Public/wap/img/caticon/ganhuo.jpg">
			</a>
			<h4>干货</h4>
			</li>
			<li
			<if condition="$_GET['type'] eq 104">class="on"</if>
			>
			<a href="{$return_url}?type=104&share={$share_para}" title="特产">
				<img src="/Public/wap/img/caticon/techan.jpg">
			</a>
			<h4>特产</h4>
			</li>
			<li
			<if condition="$_GET['type'] eq 121">class="on"</if>
			>
			<a href="{$return_url}?type=121&share={$share_para}" title="零食">
				<img src="/Public/wap/img/caticon/shucai.jpg">
			</a>
			<h4>蔬菜</h4>
			</li>
			<li
			<if condition="$_GET['type'] lt 1">class="on"</if>
			>
			<a href="{$return_url}?share={$share_para}" title="所有分类">
				<!--<a href="{:U('wap/goods/index')}" title="更多">-->
				<img src="/Public/wap/img/caticon/gengduo.jpg">
			</a>
			<h4>所有分类</h4>
			</li>
		</ul>
	</div>
	<div class="screen">
		<a href="javascript:void(0);" class=" all_chk on"  data="0" order="all_chk">
			<i class="iconfont">&#xe601</i> 新品
		</a>
		<a href="javascript:void(0);" class=" browse" data="0" order="browse">
			<i class="iconfont">&#xe653</i> 人气
			<i class="iconfont scr sx" style="display: none">&#xe457</i>
			<i class="iconfont scr xx" style="display: none">&#xe634</i>
		</a>
		<a href="javascript:void(0);" class=" sales" data="0" order="sales">
			<i class="iconfont">&#xe64f</i> 销量
			<i class="iconfont scr sx" style="display: none">&#xe457</i>
			<i class="iconfont scr xx" style="display: none">&#xe634</i>
		</a>
		<a href="javascript:void(0);" class=" prices" data="0" order="prices">
			<i class="iconfont">&#xe641</i> 价格
			<i class="iconfont scr sx" style="display: none">&#xe457</i>
			<i class="iconfont scr xx" style="display: none">&#xe634</i>
		</a>
	</div>
</div>
<div class="page">
	<div class="list more_html">
		<volist name="list" id="vo">
			<div class="goods">
				<div class="item">
					<div class="goodsimg imgnobg">
						<a href="{:U('wap/goods/goods_detail',array('id'=>$vo['goods_id'],'share'=>$share_para))}">
							<img src="{$vo.goods_img} " alt="" />
						</a>
					</div>
					<div class="form">
						<if condition="$vo.base_logo eq null" >暂无数据
							<else/>
							<img src="{$vo.base_logo}"><span>{$vo.base_name}</span>
						</if>
					</div>
					<div class="title">
						<a href="{:U('wap/goods/goods_detail',array('id'=>$vo['goods_id'],'share'=>$share_para))}">
							{$vo.goods_name}
						</a>
					</div>
					<div class="pirce">
						<span class="green">¥<span class="num">{$vo.unit_price}</span> {$vo.units}</span>
					</div>
					<div class="addcart" onclick="" goods_id="{$vo.goods_id}" img_url="{$vo.goods_img}" unit_price="{$vo.unit_price}" units="{$vo.units}"goods_attr_id="{$vo.goods_attr_id}">
						<i class="iconfont">&#xe612</i>
					</div>
				</div>
			</div>
		</volist>
	</div>
	<div class="clearfix">
	</div>
	<div class="loading">
		<div class="fm-footer-copyright get_more">
			<if condition="$count gt 10 && count($list) eq 10">
				加载更多
				<else/>
				无更多数据
			</if>
		</div>
	</div>
</div>
	<input type="hidden" name="p" data="2" value="2" />
	<input type="hidden" name="type" value="{$_GET['type']?$_GET['type']:all_chk}" />
	<input type="hidden" name="order" value="" data="" />
	<include file="Public/footer_new"/>
<script type="text/javascript">
	var load_more=0;
	var load_none=0;
	$(function(){
		//滚动加载
		$(window).scroll(function () {
			var scrollTop = $(this).scrollTop();
			var scrollHeight = $(document).height();
			var windowHeight = $(this).height();
			if (scrollTop + windowHeight == scrollHeight) {
				//此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
				if(load_none!=1){
					if(load_more==1){
						$('.get_more').html('加载中......');
					}else{
						get_more();
					}
				}
			}
		});
		$(window).load(function () {
			get_more();
		});

		//加入购物车
		$(document).on('click', '.addcart', function () {
			var goods_id = $(this).attr('goods_id');
			var goods_attr_id = $(this).attr('goods_attr_id');
			var img = $(this).attr('img');
			var goods_num = 1;
			var share = $('input[name="share"]').val();
			$.ajax({
				url: "{:U('wap/cart/add_cart')}",
				type:'get',
				data: {goods_id:goods_id,goods_attr_id:goods_attr_id,goods_num:goods_num,share:share},
				dataType: 'json',
				success: function(data){
					if(data.status==1){
						layer.msg('加入成功', {icon: 6});
						var flyer = $('<img style="display:block;width:50px;height:50px;border-radius:50px;position: fixed;z-index: 9999;" src="' + img + '">');      //抛物体对象
					}else{
						layer.msg(data.error, {icon: 5});
					}
				}
			});
		});
	});

	$(".get_more").click(function(){
		get_more();
	});

	function get_more(){
		load_more=1;
		var html=' <img src="__PUBLIC__/wap/img/icon_zhuan.gif" style="max-width:15px;">'
		$('.get_more').html('加载中'+html);
		//var p=$("input[name='p']").val();
		var search='<?php echo $_GET["search"] ?>';
		var p=$("input[name='p']").attr('data');
		var type=$("input[name='type']").val();
		var order=$("input[name='order']").val();
		$.ajax({
			url: "{:U('wap/goods/index')}",
			type:'get',
			data: {p:p,type:type,order:order, search: search},
			dataType: 'json',
			success: function(data){
				//console.log(data);
				var con=1;
				var option='';
				if(data){
					$.each(data, function(i, value) {
						//this指向当前元素
						//i表示Array当前下标
						//value表示Array当前元素
						var vip_style="";
						if(value.vip_p_show == 1){
							vip_style= 'style=" display: inline-block;"';
						}
						var base='<img src="'+value.base_logo+'"><span>'+value.base_name+'</span>';

						if(value.base_name == null || value.base_logo == null){
							base='暂无数据';
						}

						option=option+'<div class="goods">'
								+'<div class="item">'
								+'<div class="goodsimg imgnobg">'
								+'<a href="<?php echo U("wap/goods/goods_detail"); ?>?id='+value.goods_id+'&share={$share_para}"><img src="'+value.goods_img+'" alt="" /></a>'
								+'</div>'
								+'<div class="form">'+base+'</div>'
								+'<div class="title">'
								+'<a href="<?php echo U("wap/goods/goods_detail"); ?>?id='+value.goods_id+'&share={$share_para}">'+value.goods_name+'</a>'
								+'</div>'
								+'<div class="pirce">'
								+'<span class="green">¥<span class="num">'+value.unit_price+'</span>'+value.units+'</span>'
								+'</div>'

								+'<div class="addcart" onclick="" goods_id="'+value.goods_id+'" img_url="'+value.goods_img+'" unit_price="'+value.unit_price+'" units="'+value.units+'"goods_attr_id="'+value.goods_attr_id+'">'
								+'<i class="iconfont">&#xe612</i></div></div></div>';
						con++;
					});

					option += '</div>';
				}
				//$('.more_html').append(option);
				if(p==1){
					$('.more_html').html(option);
				}else{
					$('.more_html').append(option);
				}
				load_more=0;
				if(option){
					//$("input[name='p']").val(parseInt(p)+1);
					$("input[name='p']").attr('data',parseInt(p)+1);
				}
				if(con<10){
					load_none=1;
					$('.get_more').html('无更多数据');
					$('.get_more').fadeOut(3000);
				}
			}
		});
	}
	$(".screen a").click(function () {
		var data=$(this).attr('data');
		var order_by=$(this).attr('order');
		var last_click=$("input[name='order']").attr('data');
		if(last_click != order_by ){
			data = 1;
			if(order_by == 'prices'){
				data = 2 ;
			}
		}
		var order;
		$('.xx').hide();
		$('.sx').hide();
		if(data==1){
			$(this).attr('data','2');
			order=order_by+"1";
			$(this).find('.xx').show();
			$(this).find('.xx').css('display', 'inline-block');
		}else{
			$(this).attr('data','1');
			$(this).find('.sx').show();
			$(this).find('.sx').css('display', 'inline-block');
			order=order_by+"2";
		}
		$('.screen a').removeClass('on');
		$(this).addClass('on');
		//$("input[name='p']").val(1);
		$("input[name='p']").attr('data',1);
		$("input[name='order']").val(order);
		$("input[name='order']").attr('data',order_by);
		 load_more=0;
		load_none=0;
		$('.get_more').show();
		get_more();
	});
</script>

</body>
</html>